// -------------------------------------------------------------------------
//    @FileName         :    NFAsynNosql.h
//    @Author           :    GaoYi
//    @Date             :    2017-09-27
//    @Module           :   NFAsynNosql
//
// -------------------------------------------------------------------------

#pragma once

#include "NFComm/NFPluginModule/NFIPlugin.h"
#include "NFComm/NFPluginModule/NFIPluginManager.h"
#include "NFComm/NFPluginModule/NFIAsyNoSqlModule.h"
#include "NFComm/NFPluginModule/NFIKernelModule.h"
#include "NFComm/NFPluginModule/NFICommonDBModule.h"
#include "NFComm/NFPluginModule/NFIAsyMysqlModule.h"
#include "NFComm/NFPluginModule/NFIClassModule.h"
#include "NFComm/NFCore/NFProfiler.h"

class NFIAsynNosqlTest
    : public NFIModule
{
};

class NFCAsynNosqlTest
    : public NFIAsynNosqlTest
{
public:
    NFCAsynNosqlTest(NFIPluginManager* p)
    {
        pPluginManager = p;
    }

    virtual bool Init();
    virtual bool AfterInit();

    virtual bool Execute();

    virtual bool BeforeShut();
    virtual bool Shut();
public:
    void DelGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void ExistsGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void ExpireGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void ExpireatGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);

    void SetGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void GetGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void SetNXGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void SetEXGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void HSetGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void HGetGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void HDelGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
    void HExistsGaoyi(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
public:
public:
    void SetBuildData();
    void SetBuildDataRetFun(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);
public:
    void BuildObjectDataSaveToRedis();
    void BuildObjectDataSaveToRedisRet(const NFGUID& self, NFMsg::PackNoSqlParam& nosqlParam, const std::string& strUseData);

    void BuildObjectDataSaveToMysql();
    void BuildObjectDataSaveToMysqlRet(const NFGUID& self, const int ret, const std::string& strUseData);

    void BuildObjectDataLoadFromMysql();
    void LoadOfflineDataReturnFunc(const NFGUID& self, const int nRet,
                                   const std::vector<std::string>& fieldVec, const std::vector<std::string>& valueVec, const std::string& strUseData);
protected:
    uint64_t startTime = 0;
    uint64_t endTime = 0;
    int setCount = 10000;
    int setCountRetSuc = 0;
    int setCountRetFail = 0;
    int setCountRet = 0;
    NFIAsyNoSqlModule* m_pAsyNosqlModule;
    NFINoSqlModule* m_pNosqlModule;
    NFIKernelModule* m_pKernelModule;
    NFICommonDBModule* m_pCommonRedisModule;
    NFIAsyMysqlModule* m_pAsyMysqlModule;
    NFIClassModule* m_pClassModule;
};